<div id="user-block" class="text-left">
	<?php if ( user()->isGuest ) : ?>
		<div class="div-wrapper-dropdown" id="user_block_dropdown_panel">
			<a href="#" class="button button-sign-in"><i class="icon-user"></i> Login <i class="icon-small-arrow-s"></i></a>
			<div class="div-dropdown">
				
				<div id="login_form">
					<?php
					if ( empty($model) ) $model = new LoginForm();

					$form=$this->beginWidget('CActiveForm', array(
						'id' => 'login-form',
						'action' => $this->createUrl('/user/login'),
						'enableClientValidation' => false,
						'clientOptions' => array(
							'validateOnSubmit' => true,
						),
						'htmlOptions' => array(
							'class' => 'cm-ajax',
						),
					)); ?>
					<input type="hidden" name="returnUrl" value="<?php echo @$_SERVER['HTTP_REFERER'] ?>" />
					<input type="hidden" name="result_ids" value="login_form" />
					<div class="form-field row cm-required">
						<?php // echo $form->labelEx($model,'username'); ?>
						<?php echo $form->textField($model,'username', array('class' => 'input-text', 'placeholder' => $model->getAttributeLabel('username'))); ?>
						<?php echo $form->error($model,'username'); ?>
					</div>

					<div class="form-field row cm-required">
						<?php // echo $form->labelEx($model,'password'); ?>
						<?php echo $form->passwordField($model,'password', array('class' => 'input-text', 'placeholder' => $model->getAttributeLabel('password'))); ?>
						<?php echo $form->error($model,'password'); ?>
					</div>

					<div class="form-field row form-field-inline-label" style="color: gray;">
						<?php echo $form->checkBox($model,'rememberMe'); ?>
						<?php echo $form->labelEx($model,'Remember me.', array('class' => 'inline-label')); ?>
						<?php echo $form->error($model,'rememberMe'); ?>
					</div>

					<div class="form-field row buttons-container nowrap">
						<div class="row-fluid">
							<div class="span6">
								<?php echo CHtml::submitButton('Login', array('class' => 'button button2 btn-login', 'style' => 'float:left; margin-right: 10px;')); ?>
							</div>
						</div>

						<a class="orange" href="<?php echo $this->createUrl('/user/forgotPassword') ?>">Forgot Password?</a>
						<br /><a class="orange" href="<?php echo $this->createUrl('/user/register') ?>">Register Account</a>
					</div>

					<?php $this->endWidget(); ?>
				<!--login_form--></div>
			</div>
		</div>
	<?php else : ?>
		<div class="div-wrapper-dropdown" id="user_block_dropdown_panel">
			<a id="profile-button" class="button" href="#"><span><?php echo CHtml::encode(user()->firstname ? user()->firstname : user()->name) ?></span> <i class="icon-small-arrow-s"></i></a>

			<div id="user-panel-dropdown" class="div-dropdown">
				
				<div class="user-panel-row reward-row">
					Your message: <a rel="nofollow" href="<?php echo $this->createUrl('/user/notifications/') ?>"><span class="message-notification"><?php echo user()->countNotification() ?></span></a>
				</div>
				<?php $user = User::model()->findByPk(user()->id); ?>
				 
				<hr />
				<ul class="no-bullet">
					<li>&nbsp;<i class="icon-arrow-r"></i> &nbsp;<a rel="nofollow" href="<?php echo $this->createUrl('/user/profile') ?>"><span><?php echo t('My Page') ?></span></a></li>
					<li>&nbsp;<i class="icon-arrow-r"></i> &nbsp;<a rel="nofollow" href="<?php echo $this->createUrl('/user/account') ?>"><span><?php echo t('My Account') ?></span></a></li>
					<li>&nbsp;<i class="icon-arrow-r"></i> &nbsp;<a rel="nofollow" href="<?php echo $this->createUrl('/user/logout') ?>"><span><?php echo t('Sign out') ?></span></a></li>
				</ul>
				
			</div>
		</div>
	<?php endif; ?>
</div>